package CustomWidget;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.young.peopleaccommodationms.R;

/**
 * Created by young on 2016/5/29.
 */
public class TitleLayout extends LinearLayout implements View.OnClickListener{

    public TitleLayout(Context context,AttributeSet attrs) {
        super(context,attrs);
        LayoutInflater.from(context).inflate(R.layout.title, this);
        Button titleBack_btn = (Button) findViewById(R.id.title_back);
        Button titleEdit_btn = (Button) findViewById(R.id.title_edit);

        titleBack_btn.setOnClickListener(this);
        titleEdit_btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.title_edit:
                Toast.makeText(getContext(), "you clicked edit button now!",Toast.LENGTH_SHORT).show();
                break;
            case R.id.title_back:
                ((Activity)getContext()).finish();
                break;

        }
    }
}
